<?php 
include SITETPL . "header.phtml";
include SITETPL . "sidebar.phtml";
?>

<div id="container">
	<div id="loader">				
	<div class="cblock maindisplay">
<?php if(strlen($module)==0) :
    $bannerarr=DB::fetchall(" select * from tbl_gallery");
    ?>
    <div class="showcase" id="promo_slides">
        <?php foreach($bannerarr as $arr):?>
    	<div class="showcase-slide">
    		<a href="<?php echo $arr["url"] ; ?>"><img src="images/banners/<?php echo $arr["filename"] ; ?>" alt=""></a>
    	</div>
       <?php endforeach; ?>
    </div>

    <script type="text/javascript">

	$(document).ready(function()
	{
		$("#promo_slides").awShowcase(
		{
			content_width:			700,
			content_height:			240,
			fit_to_parent:			false,
			auto:					true,
			interval:				3000,
			continuous:				false,
			loading:				true,
			tooltip_width:			200,
			tooltip_icon_width:		32,
			tooltip_icon_height:	32,
			tooltip_offsetx:		18,
			tooltip_offsety:		0,
			arrows:					false,
			buttons:				true,
			btn_numbers:			false,
			keybord_keys:			false,
			mousetrace:				false, /* Trace x and y coordinates for the mouse */
			pauseonover:			true,
			stoponclick:			false,
			transition:				'fade', /* hslide/vslide/fade */
			transition_delay:		0,
			transition_speed:		300,
			show_caption:			'onload', /* onload/onhover/show */
			thumbnails:				false,
			thumbnails_position:	'outside-last', /* outside-last/outside-first/inside-last/inside-first */
			thumbnails_direction:	'vertical', /* vertical/horizontal */
			thumbnails_slidex:		1, /* 0 = auto / 1 = slide one thumbnail / 2 = slide two thumbnails / etc. */
			dynamic_height:			false, /* For dynamic height to work in webkit you need to set the width and height of images in the source. Usually works to only set the dimension of the first slide in the showcase. */
			speed_change:			true, /* Set to true to prevent users from swithing more then one slide at once. */
			viewline:				false, /* If set to true content_width, thumbnails, transition and dynamic_height will be disabled. As for dynamic height you need to set the width and height of images in the source. */
			custom_function:		null /* Define a custom function that runs on content change */
		});
	});

	</script>
<?php endif;?>
<?php echo $clsMiddleLink->middleLink(); ?>

<?php 
	switch ($module)
	{
		case "register" :
                    //echo'fgdf';

			CommonFunc::loadFile('controller/UserController.php');
			$clsDBConn = new DBConn();
			$clsUser = new User();
			$clsUser->createUser();
			break;
               case "activateuser" :
                  
                        CommonFunc::loadFile('controller/UserController.php');
                        $clsDBConn = new DBConn();
			$clsUser = new User();
			$clsUser ->ActivateUser();
                        include SITETPL . "user/login.phtml";;
			break;
               case "doregister" :
                   //echo'qwertyiopsdfghjkl;cvbnm,';
                   
			CommonFunc::loadFile('controller/UserController.php');
			$clsDBConn = new DBConn();
			                  // echo 'Ok index doregister 2 ';

                        $clsUser = new User();
			$clsUser->doCreateUser();
			break;
			
		case "login" :
			CommonFunc::loadFile("controller/LoginController.php");
			$clsLogin = new Login();
			include SITETPL . "user/login.phtml";
			break;
                case "forgotpasswordstep1" :
			CommonFunc::loadFile("controller/UserController.php");
			$clsIUser = new User();
			include SITETPL . "user/forgotpasswordstep1.phtml";
			break;
                case "forgotpasswordstep1submit" :
			CommonFunc::loadFile("controller/UserController.php");
			$clsUser = new User();
                        $userexist=$clsUser->checkuserexist();
                        
			break;
                 case "forgotpasswordstep2" :
			CommonFunc::loadFile("controller/UserController.php");
			$clsIUser = new User();
			include SITETPL . "user/forgotpasswordstep1.phtml";
			break;
                case "forgotpasswordstep2submit" :
			CommonFunc::loadFile("controller/UserController.php");
			$clsIUser = new User();
			$clsIUser->forgotpassstep2();
			break;
                case "editprofile" :
			CommonFunc::loadFile("controller/UserController.php");
			$clsIUser = new User();
			$clsIUser->editprofile();
			break;
		 case "doeditprofile" :
			CommonFunc::loadFile('controller/UserController.php');
			$clsDBConn = new DBConn();
			$clsUser = new User();
			$clsUser->doeditprofile();
			break;
		case "dologin" :
			CommonFunc::loadFile("controller/UserController.php");
			$clsUser = new User();
			$clsUser->doLogin();
			break;
			
		case "viewproducts" : 
			$sect = $param1;
			$cat_id = $param2;
                        $where="";
			if($sect == "cat")
			{
				$section = "category";
			} else if($sect == "subcat") {
				$section = "subcategory";
			}
                        if($_POST)
                        {
                          //  print_r($_POST);

                            if($_POST["param1"] == "cat")
                            {
				$section = "category";
                            } else if($_POST["param1"] == "subcat") {
				$section = "subcategory";
                            }
                            $cat_id=$_POST["param2"];
                            if($_POST["structval"])
                            {
                                foreach($_POST["structval"] as $val){
                                 //   echo $val;
                                    $structvalsplitarr=explode("|", $val);
                                    $where.= " and P.productid in ( select F.productid from tbl_productfeatures F where  (F.structkey='".$structvalsplitarr[0]."' and F.structvalue='".$structvalsplitarr[1]."') ) ";
                                }
                            }
                            
                        }
			CommonFunc::loadFile(ADAPTOR . "Paginator.php");
			$clsPaginator = new Paginator();
			//include SITETPL . "product/products.phtml"; 
			$clsPaginator->paginator($section, 'product', 'itemsbycategory', $cat_id,$where);
		
			break;
			
        case "extranetorderlist" :
			CommonFunc::loadFile("model/Order.php");
			$modOrder = new FrontOrder();
                        $orderlist1=$modOrder->getextranetorderlist1();
                        $orderlist2=$modOrder->getextranetorderlist2();
                        $orderlist3=$modOrder->getextranetorderlist3();
                        $orderlist4=$modOrder->getextranetorderlist4();
                      //  print_r($orderlist);
			include SITETPL . "user/extranetorders.phtml";
			break;
                   case "viewextranetorders" :
			CommonFunc::loadFile("controller/OrderController.php");
                        $sect = $param1;
			$order_id = $param2;
                        $ClsOrder = new  Order();
                        $ClsOrder->getextranetorder($order_id);
                       // print_r($orderlist);
			break;
                    case "cancelorder" :
			CommonFunc::loadFile("controller/OrderController.php");
                        $sect = $param1;
			$order_id = $param2;
                        $ClsOrder = new  Order();
                        $ClsOrder->cancelorder($order_id);
                        $modOrder = new FrontOrder();
                        $orderlist1=$modOrder->getextranetorderlist1();
                        $orderlist2=$modOrder->getextranetorderlist2();
                        $orderlist3=$modOrder->getextranetorderlist3();
                        $orderlist4=$modOrder->getextranetorderlist4();
                      //  print_r($orderlist);
			include SITETPL . "user/extranetorders.phtml";
                       // print_r($orderlist);
			break;
                 case "textsearch" :
			CommonFunc::loadFile("model/Product.php");
			$modProduct = new FrontProduct();
                        $request = CommonFunc::getRequest();
			$item_arr = $modProduct->getProductsBySearch($request);
			include SITETPL . "product/itemsbysearch.phtml";
			break;
                case "powersearch" :
			CommonFunc::loadFile("model/Product.php");
			$modProduct = new FrontProduct();
                        $request = CommonFunc::getRequest();
                        print_r($request);exit;
			$item_arr = $modProduct->getProductsBySearch($request);
			include SITETPL . "product/itemsbysearch.phtml";
			break;
                case "printcartridgesearch" :
			CommonFunc::loadFile("model/Product.php");
			$modProduct = new FrontProduct();
                        $request = CommonFunc::getRequest();
			$item_arr = $modProduct->getProductsByprintcartridgesearch($request);
			include SITETPL . "product/itemsbysearch.phtml";
			break;
                case "printmodelsearch" :
			CommonFunc::loadFile("model/Product.php");
			$modProduct = new FrontProduct();
                        $request = CommonFunc::getRequest();
			$item_arr = $modProduct->getProductsByprintmodelsearch($request);
			include SITETPL . "product/itemsbysearch.phtml";
			break;
                
		case "details" :
			CommonFunc::loadFile("model/Product.php");
			$modProduct = new FrontProduct();
			$productid = $param1;
			$product_arr = $modProduct->getProductById($productid);
                        $feature_arr = $modProduct->getFeature($productid);
			include SITETPL . "product/details.phtml";
			break;
			
		case "cartlogin" :
			CommonFunc::loadFile("controller/LoginController.php");
			$clsLogin = new Login();
			$clsLogin->login();
			$arg = 'addtocart';
			
			include SITETPL . "user/login.phtml";
			break;
			
		case "addtocart" :	
			CommonFunc::loadFile('controller/CartController.php');			
			$clsCart = new Cart();
			$clsCart->addtoCart();
			break;	
			
		case "showcart" :
			CommonFunc::loadFile("model/Cart.php");
                        CommonFunc::loadFile("admin/model/Creditor.php");
                        $modcredit=new ModelCreditor();
			$modCart = new FrontCart();
			$cart_arr = $modCart->getCart();
                       // print_r($_SESSION);
                         $creditbalance=$modcredit->creditbalance($_SESSION["user_id"]);
			include SITETPL . "cart/shoppingcart.phtml";
			break;
			
		case "showsavecart" :
			CommonFunc::loadFile("model/Cart.php");
			$modCart = new FrontCart();
			$cart_id = $param1;
			$cart_arr = $modCart->getCartDetailsByCartId($cart_id);
			include SITETPL . "cart/showsavecart.phtml";
			break;
			
		case "listsavecart" :
			CommonFunc::loadFile("model/Cart.php");
			$modCart = new FrontCart();
			$cart_id = $param1;
			$user_id = CommonFunc::currentUserId();
			$cart_arr = $modCart->getSaveCartDetailsByUserId($user_id);
			include SITETPL . "cart/listsavecart.phtml";
			break;
			
		case "checkout" :
			CommonFunc::loadFile('controller/OrderController.php');		
			$clsOrder = new Order();
			$clsOrder->index();			
			break;
			
		case "printsearch" :
                        CommonFunc::loadFile("model/Product.php");
			$modProduct = new FrontProduct();
                        $request = CommonFunc::getRequest();
			$brandarr = $modProduct->getbrandsforprintesearch($request);
                        $prodbybrandarr = $modProduct->getprodbybrands($request);
			include SITETPL . "print_search.phtml";
			break;

		case "getproductidforbrandsearch" :
                        CommonFunc::loadFile("model/Product.php");
			$modProduct = new FrontProduct();
                        $request = CommonFunc::getRequest();
			$brandarr = $modProduct->getproductidfrobrandsearch($request);
                     //   exit;
                      //  print_r($brandarr);
			 echo json_encode($brandarr);
			break;
			
		case "contact" :
			include SITETPL . "contact_us.phtml";
			break;
			
		case "about" :
			include SITETPL . "about.phtml";
			break;
			
		case "docontact" :
			CommonFunc::loadFile('controller/ContactController.php');
			$clsContact = new Contact();
			$clsContact->sendMail();		
			break;
			
		default: 
			/*CommonFunc::loadFile("model/Product.php");
			$modProduct= new FrontProduct();
			$product_arr = $modProduct->getProduct();
			include SITETPL . "product/products.phtml"; */
			CommonFunc::loadFile(ADAPTOR . "Paginator.php");
			$clsPaginator = new Paginator();
			//include SITETPL . "product/products.phtml"; 
			$clsPaginator->paginator("products", "product", "products", "");
			break;
	}	
?>
		</div>
	</div>
</div>
<?php
include SITETPL . "footer.phtml";
?>